package com.katze.boot.common.properties;

import com.katze.common.env.AppEnvironment;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.nio.file.Path;

//todo 需要整合路径，可配置
@Configuration
@ConfigurationProperties(prefix = "app")
@Deprecated
public class AppProperties {
    //数据字段
    private Path dataStore;
    private Path image;
    private Path docs;
    private Path view;

    public AppProperties() {
        this.dataStore = AppEnvironment.DATA_DIR.getPath();
        this.changDataStore(this.dataStore);
    }

    public Path getDataStore() {
        return dataStore;
    }

    public void setDataStore(Path dataStore) {
        this.dataStore = dataStore;
        this.changDataStore(this.dataStore);
    }

    public Path getImage() {
        return image;
    }

    public Path getDocs() {
        return docs;
    }

    public Path getView() {
        return view;
    }

    /**
     * 调整数据目录基础路径
     * @param dataStore 数据基础路径
     */
    private void changDataStore(Path dataStore){
        this.image = dataStore.resolve("image");//图片目录
        this.docs = dataStore.resolve("docs");//文档目录
        this.view = dataStore.resolve("view");//文档目录
    }
}
